| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Camera.h
1 // Camera.h
3 //
5
6 namespace nkGraphics
7 {
13 class Camera : public Node
14 {
15 public :
16
17 // Getters
21 const Frustum& getFrustum () ;
25 nkMemory::StringView getName () const ;
29 PROJECTION_TYPE getProjectionType () const ;
33 float getPerspectiveFov () const ;
37 float getPerspectiveAspectRatio () const ;
41 float getPerspectiveOffCenterFovLeft () const ;
45 float getPerspectiveOffCenterFovRight () const ;
49 float getPerspectiveOffCenterFovTop () const ;
53 float getPerspectiveOffCenterFovBottom () const ;
57 float getOrthographicHeight () const ;
61 float getOrthographicAspectRatio () const ;
65 float getNear () const ;
69 float getFar () const ;
73 bool getAutoUpdateOnContextSwitch () const ;
77 bool getHidden () const ;
81 bool getReverseZ () const ;
85 bool getInfiniteZ () const ;
89 const nkMaths::Matrix& getViewMatrix () const ;
93 const nkMaths::Matrix& getProjectionMatrix () const ;
97 nkMaths::Matrix getViewProjMatrix () const ;
118 nkMaths::Vector getProjectionParameters () const ;
119
120 // Setters
124 virtual void setPositionRelative (const nkMaths::Vector& value) override ;
128 virtual void setPositionAbsolute (const nkMaths::Vector& value) override ;
132 virtual void translateRelative (const nkMaths::Vector& value) override ;
136 virtual void translateAbsolute (const nkMaths::Vector& value) override ;
140 virtual void setOrientationRelative (const nkMaths::Quaternion& value) override ;
144 virtual void setOrientationAbsolute (const nkMaths::Quaternion& value) override ;
148 virtual void rotateRelative (const nkMaths::Quaternion& value) override ;
152 virtual void rotateAbsolute (const nkMaths::Quaternion& value) override ;
156 virtual void setScaleRelative (const nkMaths::Vector& value) override ;
160 virtual void setScaleAbsolute (const nkMaths::Vector& value) override ;
164 virtual void applyScale (const nkMaths::Vector& value) override ;
172 void setName (nkMemory::StringView name) ;
182 void setAsPerspective (float fovRadian, float aspectRatioWidthOverHeight) ;
200 void setAsPerspectiveReverseZ (float fovRadian, float aspectRatioWidthOverHeight) ;
219 void setAsPerspectiveReverseInfiniteZ (float fovRadian, float aspectRatioWidthOverHeight) ;
231 void setAsPerspectiveOffCenter (float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian) ;
244 void setAsPerspectiveOffCenterReverseZ (float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian) ;
257 void setAsPerspectiveOffCenterReverseInfiniteZ (float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian) ;
267 void setAsOrthographic (float height, float aspectRatioWidthOverHeight) ;
278 void setAsOrthographicReverseZ (float height, float aspectRatioWidthOverHeight) ;
285 void setRange (float near, float far) ;
292 void prepareForContext (RenderContext* context) ;
302 void setAutoUpdateOnContextSwitch (bool value) ;
310 void setHidden (bool value) ;
311
312 // Updates
316 void updateViewMatrix () ;
320 void updateProjectionMatrix () ;
327 void lookAt (const nkMaths::Vector& point, const nkMaths::Vector& enforcedUp = nkMaths::Vector(0, 0, 0, 0)) ;
328
329 // Utilities
338 void getNearPlanePoints (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
347 void getFarPlanePoints (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
357 void getFrustumCornersDirectionsWorld (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
367 void getFrustumCornersDirectionsView (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
368
369 // Raycast
381 nkMaths::Vector getDirectionAtPixelWorld (int x, int y, RenderContext* fromContext = nullptr) ;
389 nkMaths::Vector getDirectionAtScreenCoordWorld (float x, float y) ;
401 nkMaths::Vector getDirectionAtPixelView (int x, int y, RenderContext* fromContext = nullptr) ;
409 nkMaths::Vector getDirectionAtScreenCoordView (float x, float y) ;
410
411 // Import / Export
412 virtual void exportClassToTree (nkExport::Node* rootNode) override ;
413 virtual void importClassFromTree (nkExport::Node* rootNode) override ;
414
415 public :
416
417 // Statics
425 static nkMemory::UniquePtr<Camera> create (System* system = nullptr) ;
426 } ;
427 }
nkGraphics::Camera::getDirectionAtPixelView
nkMaths::Vector getDirectionAtPixelView(int x, int y, RenderContext *fromContext=nullptr)
nkGraphics::Camera::setAutoUpdateOnContextSwitch
void setAutoUpdateOnContextSwitch(bool value)
nkGraphics::Camera::lookAt
void lookAt(const nkMaths::Vector &point, const nkMaths::Vector &enforcedUp=nkMaths::Vector(0, 0, 0, 0))
nkGraphics::Camera::getOrthographicHeight
float getOrthographicHeight() const
nkGraphics::Camera::setHidden
void setHidden(bool value)
nkGraphics::Camera::getProjectionMatrix
const nkMaths::Matrix & getProjectionMatrix() const
nkGraphics::Camera::getReverseZ
bool getReverseZ() const
nkGraphics::Camera::setPositionAbsolute
virtual void setPositionAbsolute(const nkMaths::Vector &value) override
nkGraphics::System
Main interface with the component system.
Definition: System.h:14
nkGraphics::Camera::updateViewMatrix
void updateViewMatrix()
nkGraphics::Camera::setAsPerspectiveOffCenter
void setAsPerspectiveOffCenter(float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian)
nkGraphics::Camera::exportClassToTree
virtual void exportClassToTree(nkExport::Node *rootNode) override
nkGraphics::Camera
Offers all controls to model a camera.
Definition: Camera.h:14
nkGraphics::Camera::create
static nkMemory::UniquePtr< Camera > create(System *system=nullptr)
nkGraphics::Camera::setAsPerspectiveOffCenterReverseInfiniteZ
void setAsPerspectiveOffCenterReverseInfiniteZ(float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian)
nkGraphics::Camera::rotateRelative
virtual void rotateRelative(const nkMaths::Quaternion &value) override
nkGraphics::Camera::getFar
float getFar() const
nkGraphics::Camera::getViewMatrix
const nkMaths::Matrix & getViewMatrix() const
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkGraphics::Camera::setAsOrthographicReverseZ
void setAsOrthographicReverseZ(float height, float aspectRatioWidthOverHeight)
nkGraphics::Camera::getPerspectiveAspectRatio
float getPerspectiveAspectRatio() const
nkGraphics::Camera::getFarPlanePoints
void getFarPlanePoints(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkGraphics::Camera::getPerspectiveOffCenterFovLeft
float getPerspectiveOffCenterFovLeft() const
nkGraphics::Camera::getAutoUpdateOnContextSwitch
bool getAutoUpdateOnContextSwitch() const
nkGraphics::Camera::getNearPlanePoints
void getNearPlanePoints(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:15
nkGraphics::Camera::setAsPerspectiveOffCenterReverseZ
void setAsPerspectiveOffCenterReverseZ(float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian)
nkGraphics::RenderContext
A rendering context, attached to a window or an offscreen texture.
Definition: RenderContext.h:14
nkGraphics::Camera::getFrustum
const Frustum & getFrustum()
nkGraphics::Camera::translateRelative
virtual void translateRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::getPerspectiveOffCenterFovRight
float getPerspectiveOffCenterFovRight() const
nkGraphics::Camera::getDirectionAtScreenCoordView
nkMaths::Vector getDirectionAtScreenCoordView(float x, float y)
nkGraphics::Camera::translateAbsolute
virtual void translateAbsolute(const nkMaths::Vector &value) override
nkGraphics::Camera::applyScale
virtual void applyScale(const nkMaths::Vector &value) override
nkGraphics::Camera::getPerspectiveOffCenterFovTop
float getPerspectiveOffCenterFovTop() const
nkGraphics::Camera::prepareForContext
void prepareForContext(RenderContext *context)
nkGraphics::Camera::getDirectionAtPixelWorld
nkMaths::Vector getDirectionAtPixelWorld(int x, int y, RenderContext *fromContext=nullptr)
nkGraphics::Camera::getDirectionAtScreenCoordWorld
nkMaths::Vector getDirectionAtScreenCoordWorld(float x, float y)
nkGraphics::Camera::getName
nkMemory::StringView getName() const
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkGraphics::Camera::rotateAbsolute
virtual void rotateAbsolute(const nkMaths::Quaternion &value) override
nkGraphics::Camera::importClassFromTree
virtual void importClassFromTree(nkExport::Node *rootNode) override
nkMemory::UniquePtr
Smart pointer owning the object instance it encapsulates.
Definition: UniquePtr.h:17
nkGraphics::Camera::updateProjectionMatrix
void updateProjectionMatrix()
nkGraphics::Camera::getHidden
bool getHidden() const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkGraphics::Camera::getFrustumCornersDirectionsWorld
void getFrustumCornersDirectionsWorld(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkGraphics::Camera::setAsPerspectiveReverseZ
void setAsPerspectiveReverseZ(float fovRadian, float aspectRatioWidthOverHeight)
nkGraphics::Camera::getOrthographicAspectRatio
float getOrthographicAspectRatio() const
nkGraphics::Camera::setAsOrthographic
void setAsOrthographic(float height, float aspectRatioWidthOverHeight)
nkGraphics::Camera::setPositionRelative
virtual void setPositionRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::setRange
void setRange(float near, float far)
nkGraphics::Camera::setScaleRelative
virtual void setScaleRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::getViewProjMatrix
nkMaths::Matrix getViewProjMatrix() const
nkGraphics::Camera::setAsPerspective
void setAsPerspective(float fovRadian, float aspectRatioWidthOverHeight)
nkGraphics::Frustum
Defines a frustum.
Definition: Frustum.h:16
nkGraphics::Camera::setAsPerspectiveReverseInfiniteZ
void setAsPerspectiveReverseInfiniteZ(float fovRadian, float aspectRatioWidthOverHeight)
nkGraphics::Camera::getNear
float getNear() const
nkGraphics::Camera::getProjectionParameters
nkMaths::Vector getProjectionParameters() const
nkGraphics::Camera::setScaleAbsolute
virtual void setScaleAbsolute(const nkMaths::Vector &value) override
nkGraphics::Camera::setName
void setName(nkMemory::StringView name)
nkGraphics::Camera::getProjectionType
PROJECTION_TYPE getProjectionType() const
nkGraphics::Node
Represents a node in a scene graph.
Definition: Node.h:16
nkGraphics
Encompasses all API of component NilkinsGraphics.
Definition: BoundingBox.h:7
nkGraphics::Camera::getPerspectiveOffCenterFovBottom
float getPerspectiveOffCenterFovBottom() const
nkGraphics::Camera::setOrientationAbsolute
virtual void setOrientationAbsolute(const nkMaths::Quaternion &value) override
nkGraphics::PROJECTION_TYPE
PROJECTION_TYPE
Lists all possible projection types for a camera.
Definition: ProjectionType.h:12
nkGraphics::Camera::getFrustumCornersDirectionsView
void getFrustumCornersDirectionsView(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkGraphics::Camera::setOrientationRelative
virtual void setOrientationRelative(const nkMaths::Quaternion &value) override
nkGraphics::Camera::getInfiniteZ
bool getInfiniteZ() const
nkGraphics::Camera::getPerspectiveFov
float getPerspectiveFov() const